<?php

namespace App\Http\Controllers\home;

use Illuminate\Http\Request;
use DB;
use App\Http\Requests;
use App\Http\Controllers\Controller;

class CommentController extends Controller
{
    public function getIndex(Request $request){
    	// 获取文章id
    	$id=$request->get('id');
    	// 获取该文章下的相关内容
    	$data=DB::table('columnarticle')
    		->join('userdetails','columnarticle.uid','=','userdetails.uid')
    		->where('columnarticle.id','=',$id)
    		->get();
    		// dd($data);
    	// return view('home.zhuanlan.comment',['data'=>$data]);

    	$pl=DB::table('comment')
    		->join('userDetails','userDetails.uid','=','comment.uid')
    		->join('columnarticle','comment.caid','=','columnarticle.id')
    		->where('columnarticle.id','=',$id)
    		->get();
    		// dd($pl);

    		return view('home.zhuanlan.comment',['pl'=>$pl],['data'=>$data]);

    }

    public function getInsert(Request $request)
    {   
        session_start();
        $id=$request->input('id');
        $text=$request->input('text');
        $userid=session('id');
        $time=time();

        $res=DB::table('comment')
            ->insert(
                ['uid'=>$userid],['caid'=>$id],['contentp'=>$text],['time'=>$time]);
        dd($time);  
    }


}
